package com.ldgame.gfx.gfxelements;

import java.util.ArrayList;
import org.lwjgl.util.vector.Vector2f;
import org.newdawn.slick.Color;

public class Label implements GfxComponent {
	private Symbol symbol;
	private String string = new String();
	private Vector2f position = new Vector2f();
	
	public Label(float size, Color color) {
		symbol = new Symbol(size, color);
	}

	@Override
	public Vector2f getPosition() {
		return position;
	}

	@Override
	public float getWidth() {
		return (float)string.length() * symbol.getWidth();
	}

	@Override
	public float getHeight() {
		return symbol.getHeight();
	}

	@Override
	public Color getColor() {
		return symbol.getColor();
	}

	@Override
	public void setPosition(Vector2f position) {
		this.position = position;
	}

	@Override
	public void setWidth(float width) {
		symbol.setWidth(width);
	}

	@Override
	public void setHeight(float height) {
		symbol.setHeight(height);
	}

	@Override
	public void setColor(Color color) {
		symbol.setColor(color);
	}

	public String getString() {
		return string;
	}

	public void setString(String string) {
		this.string = string;
	}

	@Override
	public void render() {
		for (int i = 0; i < string.length(); ++i) {
			symbol.render(position.x + ((float)i - 0.5f * ((float)string.length() - 1.0f)) * symbol.getWidth(), position.y, string.charAt(i));
		}
	}
	
	public void render(String string, Vector2f position) {
		setString(string);
		setPosition(position);
		render();
	}
	
	@Override
	public boolean add(GfxComponent component) {
		return false;
	}

	@Override
	public boolean remove(GfxComponent component) {
		return false;
	}

	@Override
	public GfxComponent getChild(int i) {
		return null;
	}

	@Override
	public ArrayList<GfxComponent> getComponents() {
		return null;
	}
}
